package com.ruoyi.wechat.api;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wechat.domain.Camp;
import com.ruoyi.wechat.service.ICampService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import static com.ruoyi.common.core.domain.AjaxResult.success;
@RestController
@RequestMapping("/wechat/camp")
public class WxCampController extends BaseController {
    @Autowired
    private RedisTemplate redisTemplate;
    @Autowired
    private ICampService campService;
    /**
     * 获取营地管理详细信息
     */

    @GetMapping(value = "/get/{campId}")
    public AjaxResult getInfo(@PathVariable("campId") String campId)
    {
        return success(campService.wxSelectCampByCampId(campId));
    }

    /**
     * 查询营地排序列表
     */
    @ApiOperation("营地排序列表")
    @GetMapping("/sort")
    public TableDataInfo list(Camp camp)
    {
        List<Camp> list = campService.wxSelectCampSortList();
        return getDataTable(list);
    }
    /**
     * 获取营地管理详细信息
     */
    @ApiOperation("获取营地管理详细信息，并记录点击量")
    @GetMapping(value = "/count/{campId}")
    public AjaxResult getInfoAndUpdateCount(@PathVariable("campId") String campId)
    {
        return success(campService.wxSelectCampByCampId(campId));
    }
    /**
     * 新增营地管理
     */


    @PostMapping("/add")
    public AjaxResult add(@RequestBody Camp camp)
    {
        return toAjax(campService.insertCamp(camp));
    }
    /**
     * 修改营地管理
     */


    @PutMapping("/update")
    public AjaxResult edit(@RequestBody Camp camp)
    {
        return toAjax(campService.updateCamp(camp));
    }

    @DeleteMapping("/delete/{campIds}")
    public AjaxResult remove(@PathVariable String[] campIds)
    {
        return toAjax(campService.deleteCampByCampIds(campIds));
    }

}
